
$(function() {
	/*初始化数据表格*/
	$("#table_datagrid").datagrid({
		fit:true,
		fitColumns:true,
		toolbar:'#dg_tb',
		striped:true,
		singleSelect:true
	});
	
	$(":input[name='oqo.keyword']").textbox({
		prompt:'货品名称/编码'
	});
	$(":input[name='oqo.supplierId']").combobox({
		width:140,
		panelHeight:null,
		editable:false
	});
	$(":input[name='oqo.brandId']").combobox({
		width:140,
		panelHeight:null,
		editable:false
	});
	$(":input[name='oqo.orderGroupType']").combobox({
		width:140,
		panelHeight:null,
		editable:false
	});
	$(":input[name='oqo.beginDate']").datebox({
		editable:false,
	}).datebox('calendar').calendar({
		validator:function(date) {
			var endDate = $(":input[name='oqo.endDate']").val();
			if (endDate) {
				endDate = new Date(endDate);
				endDate.setHours(0);
				return date <= endDate && date <= new Date();
			} 
			return date <= new Date();
		}
	});
	$(":input[name='oqo.endDate']").datebox({
		editable:false,
	}).datebox('calendar').calendar({
		validator:function(date) {
			var beginDate = $(":input[name='oqo.beginDate']").val();
			if (beginDate) {
				beginDate = new Date(beginDate);
				beginDate.setHours(0);
				return date >= beginDate && date <= new Date();
			}
			return date <= new Date();
		}
	});
});

function showChart() {
	var url = $(this).data("url") + $("#queryForm").serialize();
	$("#chartDialog").dialog({
		title:'订货报表业绩图',
		width:'90%',
		height:'90%',
		content:'<iframe src="'+url+'" width=100% height=99% frameborder=0></iframe>', 
		resizable:true
	});
}